import * as api from './api'

export default {
  // 获取分页列表
  getList: (current, size, params) => {
    return api.get(`/manage/orders/${current}/${size}`, params)
  },
  // 获取详情
  getDetail: (orderNo) => {
    return api.get(`/manage/orders/${orderNo}`)
  },
  // 获取统计
  getTotal: () => {
    return api.get('/manage/orders')
  },
  // 获取问题订单分页列表
  getProblemList: (current, size, params) => {
    return api.get(`/manage/order-report/${current}/${size}`, params)
  },
  // 获取问题订单详情
  getProblemDetail: (orderNo) => {
    return api.get(`/manage/order-report/problem/${orderNo}`)
  },
  // 获取问题订单详情
  getProblemDetailList: (orderNo) => {
    return api.get(`/manage/order-report/${orderNo}`)
  },

  // 主动扣款
  putActiveDeduction: (id) => {
    const headers = {
      'lang-key': 'activeDeduction'
    }
    return api.put(`/manage/orders/payment/${id}`, null, headers)
  },
  // 退款
  putRefund: (params) => {
    const headers = {
      'lang-key': 'refund'
    }
    return api.put('/manage/orders/refund', params, headers)
  },
  // 结束订单
  putEnd: (id) => {
    const headers = {
      'lang-key': 'Endoftheorder'
    }
    return api.put(`/manage/orders/end/${id}`, null, headers)
  },
  // 订单修改: 1-取消订单 2-优惠 3-免单
  putModifyState: (params) => {
    let langKey
    if (Number(params.state) === 1) {
      langKey = 'cancellationOrder'
    } else if (Number(params.state) === 2) {
      langKey = 'discounts'
    } else if (Number(params.state) === 3) {
      langKey = 'freeCharge'
    }
    const headers = {
      'lang-key': langKey
    }
    return api.put('/manage/orders/state', params, headers)
  },
  // 检查充电宝
  putExamine: (id) => {
    return api.get(`/manage/orders/power-bank/${id}`)
  },
  // 处理问题订单
  putDispose: (params) => {
    const headers = {
      'lang-key': 'dispose'
    }
    return api.put('/manage/order-report/audit', params, headers)
  }
}
